package com.zfskkk.democonsumerfeign;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangfoshou
 * @date 2018/11/13 18:18
 */
@Configuration
public class Config {
    @Bean
    public HystrixMetricsStreamServlet hystrixMetricsStreamServlet() {
        HystrixMetricsStreamServlet hystrixMetricsStreamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(hystrixMetricsStreamServlet);
        registrationBean.setLoadOnStartup(1);
        List<String> list = new ArrayList<>();
        list.add("/hystrix.stream");
        registrationBean.setUrlMappings(list);
        registrationBean.setName("hystrixMetricsStreamServlet");
        return hystrixMetricsStreamServlet;
    }
}
